#pragma once

/// <summary>
/// SysInput: Responsible for managing and updating player input devices
/// <summary>

/**	
  * Author: Michael Leviston
  * Created: 05/06/13
  * Last Modified: 30/06/13
  * Version: V1
  */

// Includes
#include "common\InputClass.h"
#include "Camera.h"
#include "ControllerInput.h"

// Class Definition
class SysInput
{
public:
//==============================
// Constructors / Destructors
//==============================

	/// Default Constructor
	SysInput();

	/// Default Destructor
	~SysInput();

//==============================
// Initialise
//==============================

  /**
	* Initialise the input system
	*
	* @param Pointer to the camera system
	* @param Application Instance
	* @param Main App Window
	* @param Window Width
	* @param Window Height
	*/
	void Initialise(Camera* pCamera, HINSTANCE hInstance, HWND hwnd, int ScreenWidth, int ScreenHeight);

//==============================
// Update
//==============================

  /**
	* Update the input system
	*
	* @param Delta Time since last update
	* @param Camera Dollying Distance
	*/
	void Update(float dt, float* distInc);


//==============================
// Get and Set Methods
//==============================

  /**
	* Get camera dollying state
	*
	* @return Is the camera dollying out
	*/
	bool GetDollyOut() const;

  /**
    * Set camera dollying state
	*
	* @param New state
	*/
	void SetDollyOut(bool dolly);

  /**
    * Get the input velocity
	*
	* @return XMFLOAT3 containing velocity
	*/
	XMFLOAT3 GetVelocity();

  /**
    * Set input velocity
	*
	* @param New input velocity
	*/
	void SetVelocity(XMFLOAT3 velocity);

	/// Normalise the input velocity
	void NormaliseVelocity();
	
private:
//==============================
// Update
//==============================

	/// Update Keyboard Input
	void UpdateKeyboardInput(float dt);

	/// Update Mouse Input
	void UpdateMouseInput();

  /**
    * Update Controller Input
	*
	* @param Delta Time since last update
	* @param Bool - Is the controller enabled
	* @param Float - Camera Dolly Distance
	*/
	void UpdateControllerInput(float dt, bool bControllerEnabled, float* distInc);

private:
	Camera*				m_pCamera;				///< Pointer to Camera System
	InputClass*			m_pInput;				///< Pointer to mouse/keyboard input
	ControllerInput*	m_pController;			///< Pointer to gamepad input

	POINT				m_last_mouse_pos;		///< Positon of the mouse cursor last update
	XMFLOAT3			m_inputVelocity;		///< Input velocity is the sum velocity of the various input methods
	bool				m_dollyOut;				///< Is the camera trying to dolly out
	bool				m_controllerEnabled;	///< Is the gamepad controller enabled

	bool				m_bPrevThirdPerson;		///< Was the camera in third person last update
};